import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_common/global_info.dart';
import 'package:basic_widgets/app_bar_widget.dart';
import 'package:basic_widgets/button_widget.dart';
import 'package:basic_widgets/text_widget.dart';
import 'setting_controller.dart';
class SettingPage extends GetView<SettingController> {
  const SettingPage({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: backAppbar(title: '设置'),
        body: Container(
          color: Colors.white,
          child: Column(
            children: [
              // GestureDetector(
              //   onTap: () => {Get.offAndToNamed(AppRoutes.personal)},
              //   child: buildItem(title: '个人资料'),
              // ),
              GestureDetector(
                onTap: () => Get.toNamed(AppRoutes.resetpwd),
                child: buildItem(title: '修改密码'),
              ),
              GestureDetector(
                onTap: () => {Get.toNamed(AppRoutes.authifo)},
                child: buildItem(title: '认证资料'),
              ),
              // GestureDetector(
              //   onTap: () {
              //     // Get.toNamed(AppRoutes.settingCer);
              //     controller.getAccountList();
              //   },
              //   child: buildItem(title: '设置移动证书'),
              // ),
              GestureDetector(
                onTap: () {
                  controller.updateNewVer();
                },
                child: buildItem(
                    title: '升级版本',
                    isExtra: true,
                    extraWidget: Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text(
                          '当前版本${GlobalInfo.version}',
                          style: TextStyle(color: AppTheme.weakTextColor),
                        ),
                        Image.asset(
                          "assets/profile/icon_arrow_next.png",
                          width: ScreenHelper.width(18),
                          package: "basic_common",
                        )
                      ],
                    )),
              ),
              GestureDetector(
                onTap: () => Get.toNamed(AppRoutes.about),
                child: buildItem(title: '关于我们'),
              ),
              Spacer(),
              Padding(
                padding:
                    EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
                child: Row(
                  children: [
                    Expanded(
                      child: roundBtn(
                          text: "退出登录",
                          bgColor: Colors.white,
                          textColor: AppTheme.primyColor,
                          onTap: () {
                            GlobalInfo.exitApp();
                          }),
                    ),
                  ],
                ),
              ),
              SizedBox(
                height: ScreenHelper.height(20),
              )
            ],
          ),
        ));
  }

  /// 设置Item项目
  buildItem(
      {required String title, bool isExtra = false, Widget? extraWidget}) {
    return Container(
      alignment: Alignment.centerLeft,
      color: Colors.white,
      child: ListTile(
        leading: SizedBox.shrink(),
        minLeadingWidth: ScreenHelper.width(4),
        title: norTitle(title: title),
        trailing: !isExtra
            ? Image.asset(
                "assets/profile/icon_arrow_next.png",
                width: ScreenHelper.width(18),
                package: "basic_common",
              )
            : extraWidget,
      ),
    );
  }
}

